<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <script src="https://img.hcharts.cn/highcharts/highcharts.js"></script>
</head>

<body>

<div id="humidity" style="height: 200px;"></div>

<script>

   function set(data){
                    var dataX = [];
                    var dataY = [];
                    var records = JSON.parse(data);

                    var total = records.length;
                    var totalSum = 0;
                    var size = 30;
                    var totalSize = parseInt(total/size);
                    var t = 6;
                    for (var j = 0; j < records.length; j++) {
                    var item = records[j];
                    if(item.humidity&&item.recordAt&&total%totalSize==0){
                     dataX.push(item.recordAt);
                     dataY.push(item.humidity*1.0);
                     totalSum++;
                    }
                    }
                    if(totalSum>0&&totalSum<size){

                    }else if(totalSum>0){
                     t = parseInt(t*totalSum/size);
                    }
                    var chart = new Highcharts.Chart('humidity', {
                            chart: {
                                type: 'line'                         //指定图表的类型，默认是折线图（line）
                            },
                            title: {
                                text: '湿度监控显示（%）'                //指定图表标题
                            },
                            xAxis: {
                                tickInterval: t,
                                categories: dataX //指定x轴分组
                            },
                            yAxis: {
                                title: {
                                    text: '温度'                //指定y轴的标题
                                }
                            },
                            credits: {
                                enabled: false
                            },
                            series: [{                              //指定数据列
                                name: '湿度',                       //数据列名
                                data: dataY,                  //数据
                                zones: [{
                                    value: -100,
                                    color: '#379DF2'
                                }]
                            }]
                        });


                }

</script>
</body>

</html>